import store from 'store';
import moment from 'moment';

export default {
	state: {
		index: 0,
		open: false
	},

	mutations: {
		OPEN_GUIDE(state, index) {
			const oldIndex = store.get('guide-index') || '';

			if (String(oldIndex).includes('close')) {
				return false;
			}

			if (!oldIndex && index != 1) {
				return false;
			}

			state.index = index;
			state.open = true;

			store.set('guide-index', index);
		},
		CLOSE_GUIDE(state) {
			state.open = false;
		},
		CLEAR_GUIDE(state) {
			state.open = false;
			store.set('guide-index', `close-${moment().format('YYYY-MM-DD HH:mm:ss')}`);
		}
	}
};
